package a16_visitor.oa_visitor_sample;

/**
 * 员工的信息结构一般来说是固定的，</br>
 * hr部门和财务部门对员工的数据进行统计计算的算法可能随着职位等变化，是不定的，</br>
 * 所以使用访问者模式将变和不变的部分分离</br>
 * 使得于扩展和修改
 * 
 *
 */
public class Client {

	public static void main(String[] args) {

		// make employee list
		ElementStructure es = new ElementStructure();
		for (int i = 0; i < 1000; i++) {
			String name = "emp_" + i;
			if (i % 2 == 0) {
				es.addEmployee(new FullTimeEmployee(name));
			} else {
				es.addEmployee(new PartTimeEmployee(name));
			}

		}
		// visitor
		IDepartment hr = new HRDepartment();
		IDepartment finance = new FinanceDepartment();
		// visit the elements
		for (AbstractEmployee node : es.getNodes()) {
			node.accecpt(hr);
			node.accecpt(finance);
		}
	}
}
